package zhibi.cms.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import zhibi.frame.springmvc.interceptor.AdminInterceptor;
import zhibi.frame.springmvc.interceptor.ParamInterceptor;

import static zhibi.cms.extra.context.Constant.SYS_PREFIX;


@Configuration
public class WebConfig extends WebMvcConfigurerAdapter {

    @Autowired
    private ParamInterceptor paramInterceptor;
    @Autowired
    private AdminInterceptor adminInterceptor;


    /**
     * 添加拦截器
     *
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(paramInterceptor).addPathPatterns("/**");
        adminInterceptor.setAdminLoginUrl( "/cms/admin/login");
        registry.addInterceptor(adminInterceptor).addPathPatterns( "/cms/admin/**")
                .excludePathPatterns("/cms/admin/login", "/cms/admin/logout");
        super.addInterceptors(registry);
    }


}
